package stu.sup.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stu.sup.entity.AddressInfo;
import stu.sup.mapper.AddressInfoMapper;
import stu.sup.service.IAdressInfoService;

/**
 * Created by HUAWEI on 2020/6/23.
 */
@Service
@Transactional
public class AdressInfoServiceImpl implements IAdressInfoService{
    @Autowired
    AddressInfoMapper addressInfoMapper;
    @Override
    public boolean addAdress(int loginId, String username, Integer telephone, String adress) {
        AddressInfo addressInfo=new AddressInfo();
        addressInfo.setUserLoginId(loginId);
        addressInfo.setName(username);
        addressInfo.setTelephone(telephone);
        addressInfo.setAddress(adress);
       int count=addressInfoMapper.insert(addressInfo);
        return count==0?false:true;
    }

    @Override
    public boolean delate(int id) {
        int count=addressInfoMapper.deleteByPrimaryKey(id);
        return count==0?false:true;
    }

    @Override
    public boolean update(AddressInfo addressInfo) {
        int count=addressInfoMapper.updateByPrimaryKey(addressInfo);
        return count==0?false:true;
    }

    @Override
    public AddressInfo find(int id) {
        AddressInfo addressInfo=addressInfoMapper.selectByPrimaryKey(id);
        return addressInfo;
    }
}
